package com.itheima.repository;

import com.itheima.domain.Discuss;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.*;
import javax.transaction.Transactional;
import java.util.List;


public interface DiscussRepository extends JpaRepository<Discuss,Integer> {
    public List<Discuss> findByAuthorNotNull();
    @Query("SELECT c FROM t_comment c WHERE c.aId=?1")
    public List<Discuss> getDiscussPaged(Integer aid, Pageable pageable);
    @Query(value ="SELECT * FROM t_comment WHERE a_id=?1",nativeQuery = true)
    public List<Discuss> getDiscussespaged2 (Integer aid, Pageable pageable);
    @Transactional
    @Modifying
    @Query("UPDATE t_comment c SET c.author =?1 where c.id =?2")
    public int updateDiscuss(String author, Integer id);
    @Transactional
    @Modifying
    @Query("DELETE FROM t_comment  where c.id =?1")
    public int deleteDiscuss(Integer id);
}
